const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    devtool: "source-map",
    entry: [
        "./src/app/index.js"
    ],
    output: {
        path: "./bin",
        filename: "app.bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            },
            {
                test: /\.css$/,
                loaders: ["style", "css"]
            },
            // used for bootstrap
            { 
                test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, 
                loader: "file-loader" 
            },
            // sass
            {
                test: /\.sass$/,
                loader: "style!css!sass"
            },
            // scss
            {
                test: /\.scss$/,
                loader: "style!css!sass"
            },
            // json
            {
                test: /\.json$/,
                loader: "json"
            },
            {
                test: /\.(png|jpg)$/, 
                loader: "url-loader?limit=8192"
            }
        ]    
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                warnings: false,
            },
        }),
        new webpack.optimize.OccurrenceOrderPlugin(),
        new HtmlWebpackPlugin({
            template: "./src/app/index.html"
        }),
				// export the jquery module to global
        new webpack.ProvidePlugin({
            "jQuery": "jquery",
            "$": "jquery",
            "window.jQuery": "jquery"
        })
    ]
};